﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using WindowsGame1.CoreComponents;

namespace WindowsGame1.SpriteClasses
{
    class LaserBall : Sprite
    {
        SpriteBatch sprite;
        Rectangle location;
        float speed;
        bool isMine;

        public LaserBall(Game game, Texture2D texture, Vector2 pos, bool isMine)
            : base(game, texture)
        {
            this.isMine = isMine;
            sprite = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch));
            location = new Rectangle((int)pos.X,
            (int)pos.Y,
            30,
            30);
            if (isMine)
                this.speed = 10f;
            else
                this.speed = -10f;
        }
       
        public override void Update(GameTime gameTime)
        {
            location.X=location.X+1*(int)speed;
            Position = new Vector2(location.X, location.Y);
        }

        public override void Draw(GameTime gameTime)
        {

            if (location.X < 1000 && location.X > 0)
            {
                spriteBatch.Draw(texture,
                location,
                Color.White);
            }
        }
    }
}
